﻿using System;
using System.Text;
using System.Text.RegularExpressions;

namespace ReverseWordsInSentance
{
    public class Program
    {
        public static void Main()
        {
            string sentance = "A lass is picking, berries.";
            string pattern = @"\w+|\W+";

            StringBuilder sb = new StringBuilder();
            var matches = Regex.Matches(sentance, pattern, RegexOptions.RightToLeft);
            for (int i = 1; i < matches.Count; i++)
            {
                sb.Append(matches[i].Value.ToLower());
            }
            sb.Append(matches[0].Value);
            Console.WriteLine(sb.ToString()[0].ToString().ToUpper() + sb.ToString().Substring(1));
        }
    }
}
